<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
require_once("lib/my_library.php");
//Includes
use_unit("comctrls.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("components4phpfull/jtdivwindow.inc.php");
use_unit("components4phpfull/jtgroupbox.inc.php");
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtdatepicker.inc.php");
use_unit("components4phpfull/jtdatetimepicker.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Veh_Reminder_create extends Page
{
       public $edDesc = null;
       public $COMPLETION_TYPE = null;
       public $dpDue = null;
       public $lblb4 = null;
       public $cmbDaysMos = null;
       public $edRemind = null;
       public $Label4 = null;
       public $cmbdm = null;
       public $ednum = null;
       public $lblkm = null;
       public $edEvery = null;
       public $chkRec = null;
       public $lblEvery = null;
       public $imgBack = null;
       public $Button1 = null;
       public $hftrack = null;
       public $lblhr = null;
       public $dpDue2 = null;
       public $btnCancel = null;
       public $btnSubmit = null;
       public $JTDivType = null;
       public $JTGroupBox1 = null;
       public $btnAddType = null;
       public $btnDelType = null;
       public $edType = null;
       public $listType = null;
       public $btnShowType = null;
       public $JTJavaScript3 = null;
       public $JTJavaScript2 = null;
       public $JTJavaScript1 = null;
       public $compid = null;
       public $cmbcompletion = null;
       public $Label3 = null;
       public $edPrice = null;
       public $lblFixedPrice = null;
       public $Image3 = null;
       public $hiddenId = null;
       public $lblDueat = null;
       public $lblOrby = null;
       public $lblDueby = null;
       public $JTSiteTheme1 = null;
       public $lblHours = null;
       public $cmbVendor = null;
       public $memoComments = null;
       public $lblComments = null;
       public $Label2 = null;
       public $cmbType = null;
       public $lblType = null;
       public $Label5 = null;
       public $edDue = null;
       public $cmbSchedule = null;
       public $Label1 = null;
       function edRemindJSKeyUp($sender, $params)
       {

       ?>
       var numero = document.getElementById("edRemind").value;
       var first = numero.indexOf('.');
       var last = numero.lastIndexOf('.');

       while(isNaN(numero))
       {
        haba = numero.length;
        haba = haba - 1;
        numero = numero.substr(0,haba);
       }

       while(first!=last)
       {
        numero = numero.slice(0,last);
        first = numero.indexOf('.');
        last = numero.lastIndexOf('.');
       }
       document.getElementById("edRemind").value = numero;

       <?php

       }

       function edEveryJSKeyUp($sender, $params)
       {

       ?>
       var numero = document.getElementById("edEvery").value;
       var first = numero.indexOf('.');
       var last = numero.lastIndexOf('.');

       while(isNaN(numero))
       {
        haba = numero.length;
        haba = haba - 1;
        numero = numero.substr(0,haba);
       }

       while(first!=last)
       {
        numero = numero.slice(0,last);
        first = numero.indexOf('.');
        last = numero.lastIndexOf('.');
       }
       document.getElementById("edEvery").value = numero;

       <?php

       }

       function edDueJSKeyUp($sender, $params)
       {

       ?>
       var numero = document.getElementById("edDue").value;
       var first = numero.indexOf('.');
       var last = numero.lastIndexOf('.');

       while(isNaN(numero))
       {
        haba = numero.length;
        haba = haba - 1;
        numero = numero.substr(0,haba);
       }

       while(first!=last)
       {
        numero = numero.slice(0,last);
        first = numero.indexOf('.');
        last = numero.lastIndexOf('.');
       }
       document.getElementById("edDue").value = numero;

       <?php

       }

       function chkRecJSChange($sender, $params)
       {

       ?>
       var chk = document.getElementById('chkRec').checked;
       if(chk==true)
       {
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';

       var track = document.getElementById('cmbSchedule').value;
       var hr = document.getElementById('lblhr_outer');
       var km = document.getElementById('lblHours_outer');
       var dueat = document.getElementById('lblDueat_outer');
       var dueby = document.getElementById('lblDueby_outer');
       var every = document.getElementById('lblEvery_outer');
       var ednum = document.getElementById('ednum_outer');
       var dm = document.getElementById('cmbdm_outer');
       var b4 = document.getElementById('lblb4');
       var DaysMos = document.getElementById('cmbDaysMos_outer');
       var remind = document.getElementById('edRemind');
       if(track=='Date')
       {
       //alert('date');
       document.getElementById('lblDueby').style.visibility = 'visible';
       document.getElementById('f-calendar-field-1').style.visibility = 'visible';
       document.getElementById('edDue_outer').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'hidden';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'visible';
       document.getElementById('ednum_outer').style.visibility='visible';
       document.getElementById('cmbdm_outer').style.visibility='visible';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='hidden';
       document.getElementById('lblkm_outer').style.visibility='hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='visible';
       document.getElementById('lblb4').innerHTML="before due date";
       remind.style.width='61px';
       hr.style.left = '224px';
       km.style.left = '224px';
       dueat.style.left = '150px';
       dueby.style.left = '56px';
       every.style.left = '334px';
       ednum.style.left = '392px';
       dm.style.left = '472px';
       DaysMos.style.left = '212px';
       b4.style.left = '334px';
       }

       if(track=='Mileage')
       {
       //alert('mileage');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';
       document.getElementById('lblkm').innerHTML="Km";
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Km before due";
       remind.style.width='181px';
       hr.style.left = '224px';
       km.style.left = '334px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       every.style.left = '381px';
       ednum.style.left = '670px';
       dm.style.left = '750px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }

       if(track=='Hours')
       {
       //alert('hours');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'visible';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';
       document.getElementById('lblkm').innerHTML="Hours";
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Hours before due";
       remind.style.width='181px';
       hr.style.left = '334px';
       km.style.left = '224px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       every.style.left = '381px';
       ednum.style.left = '670px';
       dm.style.left = '750px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }
       }
       if(chk==false)
       {
       document.getElementById('edEvery_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='hidden';
       document.getElementById('lblkm_outer').style.visibility='hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';

       var track = document.getElementById('cmbSchedule').value;
       var hr = document.getElementById('lblhr_outer');
       var km = document.getElementById('lblHours_outer');
       var dueat = document.getElementById('lblDueat_outer');
       var dueby = document.getElementById('lblDueby_outer');
       var b4 = document.getElementById('lblb4');
       var DaysMos = document.getElementById('cmbDaysMos_outer');
       var remind = document.getElementById('edRemind');

       if(track=='Date')
       {
       //alert('date');
       document.getElementById('lblDueby').style.visibility = 'visible';
       document.getElementById('f-calendar-field-1').style.visibility = 'visible';
       document.getElementById('edDue_outer').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'hidden';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'visible';
       document.getElementById('cmbDaysMos_outer').style.visibility='visible';
       document.getElementById('lblb4').innerHTML="before due date";
       remind.style.width='61px';
       hr.style.left = '224px';
       km.style.left = '224px';
       dueat.style.left = '150px';
       dueby.style.left = '56px';
       DaysMos.style.left = '212px';
       b4.style.left = '334px';
       }

       if(track=='Mileage')
       {
       //alert('mileage');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Km before due";
       remind.style.width='181px';
       hr.style.left = '224px';
       km.style.left = '334px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       DaysMos.style.left = '334px';
       b4.style.left = '212px';
       }

       if(track=='Hours')
       {
       //alert('hours');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'visible';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Hours before due";
       remind.style.width='181px';
       hr.style.left = '334px';
       km.style.left = '224px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }
       }
       <?php

       }

       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back.png"
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back2.png"
       <?php

       }

       function Button1JSClick($sender, $params)
       {

       ?>
       document.getElementById('lblhr_outer').style.visibility = 'visible';

       <?php

       }

       function Veh_Reminder_createJSLoad($sender, $params)
       {

       ?>
       //Add your javascript code here
       var chk = document.getElementById('chkRec').checked;
       if(chk==true)
       {
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';

       var track = document.getElementById('cmbSchedule').value;
       var hr = document.getElementById('lblhr_outer');
       var km = document.getElementById('lblHours_outer');
       var dueat = document.getElementById('lblDueat_outer');
       var dueby = document.getElementById('lblDueby_outer');
       var every = document.getElementById('lblEvery_outer');
       var ednum = document.getElementById('ednum_outer');
       var dm = document.getElementById('cmbdm_outer');
       var b4 = document.getElementById('lblb4');
       var DaysMos = document.getElementById('cmbDaysMos_outer');
       var remind = document.getElementById('edRemind');
       if(track=='Date')
       {
       //alert('date');
       document.getElementById('lblDueby').style.visibility = 'visible';
       document.getElementById('f-calendar-field-1').style.visibility = 'visible';
       document.getElementById('edDue_outer').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'hidden';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'visible';
       document.getElementById('ednum_outer').style.visibility='visible';
       document.getElementById('cmbdm_outer').style.visibility='visible';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='hidden';
       document.getElementById('lblkm_outer').style.visibility='hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='visible';
       document.getElementById('lblb4').innerHTML="before due date";
       remind.style.width='61px';
       hr.style.left = '224px';
       km.style.left = '224px';
       dueat.style.left = '150px';
       dueby.style.left = '56px';
       every.style.left = '334px';
       ednum.style.left = '392px';
       dm.style.left = '472px';
       DaysMos.style.left = '212px';
       b4.style.left = '334px';
       }

       if(track=='Mileage')
       {
       //alert('mileage');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';
       document.getElementById('lblkm').innerHTML="Km";
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Km before due";
       remind.style.width='181px';
       hr.style.left = '224px';
       km.style.left = '334px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       every.style.left = '381px';
       ednum.style.left = '670px';
       dm.style.left = '750px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }

       if(track=='Hours')
       {
       //alert('hours');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'visible';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';
       document.getElementById('lblkm').innerHTML="Hours";
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Hours before due";
       remind.style.width='181px';
       hr.style.left = '334px';
       km.style.left = '224px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       every.style.left = '381px';
       ednum.style.left = '670px';
       dm.style.left = '750px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }
       }
       if(chk==false)
       {
       document.getElementById('edEvery_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='hidden';
       document.getElementById('lblkm_outer').style.visibility='hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';

       var track = document.getElementById('cmbSchedule').value;
       var hr = document.getElementById('lblhr_outer');
       var km = document.getElementById('lblHours_outer');
       var dueat = document.getElementById('lblDueat_outer');
       var dueby = document.getElementById('lblDueby_outer');
       var b4 = document.getElementById('lblb4');
       var DaysMos = document.getElementById('cmbDaysMos_outer');
       var remind = document.getElementById('edRemind');

       if(track=='Date')
       {
       //alert('date');
       document.getElementById('lblDueby').style.visibility = 'visible';
       document.getElementById('f-calendar-field-1').style.visibility = 'visible';
       document.getElementById('edDue_outer').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'hidden';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'visible';
       document.getElementById('cmbDaysMos_outer').style.visibility='visible';
       document.getElementById('lblb4').innerHTML="before due date";
       remind.style.width='61px';
       hr.style.left = '224px';
       km.style.left = '224px';
       dueat.style.left = '150px';
       dueby.style.left = '56px';
       DaysMos.style.left = '212px';
       b4.style.left = '334px';
       }

       if(track=='Mileage')
       {
       //alert('mileage');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Km before due";
       remind.style.width='181px';
       hr.style.left = '224px';
       km.style.left = '334px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       DaysMos.style.left = '334px';
       b4.style.left = '212px';
       }

       if(track=='Hours')
       {
       //alert('hours');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'visible';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Hours before due";
       remind.style.width='181px';
       hr.style.left = '334px';
       km.style.left = '224px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }
       }
       <?php

       }

       function cmbScheduleJSChange($sender, $params)
       {

       ?>
       //Add your javascript code here
       var chk = document.getElementById('chkRec').checked;
       if(chk==true)
       {
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';

       var track = document.getElementById('cmbSchedule').value;
       var hr = document.getElementById('lblhr_outer');
       var km = document.getElementById('lblHours_outer');
       var dueat = document.getElementById('lblDueat_outer');
       var dueby = document.getElementById('lblDueby_outer');
       var every = document.getElementById('lblEvery_outer');
       var ednum = document.getElementById('ednum_outer');
       var dm = document.getElementById('cmbdm_outer');
       var b4 = document.getElementById('lblb4');
       var DaysMos = document.getElementById('cmbDaysMos_outer');
       var remind = document.getElementById('edRemind');
       if(track=='Date')
       {
       //alert('date');
       document.getElementById('lblDueby').style.visibility = 'visible';
       document.getElementById('f-calendar-field-1').style.visibility = 'visible';
       document.getElementById('edDue_outer').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'hidden';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'visible';
       document.getElementById('ednum_outer').style.visibility='visible';
       document.getElementById('cmbdm_outer').style.visibility='visible';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='hidden';
       document.getElementById('lblkm_outer').style.visibility='hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='visible';
       document.getElementById('lblb4').innerHTML="before due date";
       remind.style.width='61px';
       hr.style.left = '224px';
       km.style.left = '224px';
       dueat.style.left = '150px';
       dueby.style.left = '56px';
       every.style.left = '334px';
       ednum.style.left = '392px';
       dm.style.left = '472px';
       DaysMos.style.left = '212px';
       b4.style.left = '334px';
       }

       if(track=='Mileage')
       {
       //alert('mileage');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';
       document.getElementById('lblkm').innerHTML="Km";
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Km before due";
       remind.style.width='181px';
       hr.style.left = '224px';
       km.style.left = '334px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       every.style.left = '381px';
       ednum.style.left = '670px';
       dm.style.left = '750px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }

       if(track=='Hours')
       {
       //alert('hours');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'visible';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';
       document.getElementById('lblkm').innerHTML="Hours";
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Hours before due";
       remind.style.width='181px';
       hr.style.left = '334px';
       km.style.left = '224px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       every.style.left = '381px';
       ednum.style.left = '670px';
       dm.style.left = '750px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }
       }
       if(chk==false)
       {
       document.getElementById('edEvery_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='hidden';
       document.getElementById('lblkm_outer').style.visibility='hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';

       var track = document.getElementById('cmbSchedule').value;
       var hr = document.getElementById('lblhr_outer');
       var km = document.getElementById('lblHours_outer');
       var dueat = document.getElementById('lblDueat_outer');
       var dueby = document.getElementById('lblDueby_outer');
       var b4 = document.getElementById('lblb4');
       var DaysMos = document.getElementById('cmbDaysMos_outer');
       var remind = document.getElementById('edRemind');

       if(track=='Date')
       {
       //alert('date');
       document.getElementById('lblDueby').style.visibility = 'visible';
       document.getElementById('f-calendar-field-1').style.visibility = 'visible';
       document.getElementById('edDue_outer').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'hidden';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'visible';
       document.getElementById('cmbDaysMos_outer').style.visibility='visible';
       document.getElementById('lblb4').innerHTML="before due date";
       remind.style.width='61px';
       hr.style.left = '224px';
       km.style.left = '224px';
       dueat.style.left = '150px';
       dueby.style.left = '56px';
       DaysMos.style.left = '212px';
       b4.style.left = '334px';
       }

       if(track=='Mileage')
       {
       //alert('mileage');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Km before due";
       remind.style.width='181px';
       hr.style.left = '224px';
       km.style.left = '334px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       DaysMos.style.left = '334px';
       b4.style.left = '212px';
       }

       if(track=='Hours')
       {
       //alert('hours');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'visible';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Hours before due";
       remind.style.width='181px';
       hr.style.left = '334px';
       km.style.left = '224px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }
       }
       <?php

       }



       function btnDelTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var TypeIndex = document.getElementById('listType').selectedIndex;
       var TypeValue = document.getElementById('listType')[TypeIndex].value;
       var compider3 = document.getElementById('compid').value;
       AjaxType3(TypeValue,compider3);
       <?php

       }

       function btnAddTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addtype = document.getElementById('edType').value;
       var compider = document.getElementById('compid').value;
       AjaxType2(addtype,compider);
       document.getElementById('edType').value = " "
       <?php

       }

       function btnShowTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivType').Show();
       document.getElementById('edType').value = "";
       <?php

       }

       function cmbcompletionJSChange($sender, $params)
       {
       //echo $this->cmbcompletion->ajaxCall('CompletionChange');
       ?>
       completionWindow();
       return false;
       <?php

       }


       function btnCancelClick($sender, $params)
       {
       redirect('check_reminder.php?veh='.$this->hiddenId->getValue());


       }


       function CompletionChange()
       {
       $completion = $this->cmbcompletion->getItemIndex();

       if($completion=="WorkOrder")
       {
        $this->cmbType->Clear();
        $result_type = mysql_query("select * from lookup_workorder_tbl where company_id='".$_SESSION['company_id']."' and category='type'");

          while($row_type = mysql_fetch_array($result_type))
          {
            $this->cmbType->AddItem($row_type['value'], null, $row_type['value']);
          }
       }

       if($completion=="Payment")
       {
        $this->cmbType->Clear();
        $result_type = mysql_query("select * from lookup_expense_tbl where company_id='".$_SESSION['company_id']."' and category='types'");

          while($row_type = mysql_fetch_array($result_type))
          {
            $this->cmbType->AddItem($row_type['value'], null, $row_type['value']);
          }
       }

       if($completion=="None")
       {
        $this->cmbType->Clear();
        $result_type = mysql_query("select * from lookup_expense_tbl where company_id='".$_SESSION['company_id']."' and category='types'");

          while($row_type = mysql_fetch_array($result_type))
          {
            $this->cmbType->AddItem($row_type['value'], null, $row_type['value']);
          }
       }

       return false;
       }


       function Veh_Reminder_createCreate($sender, $params)
       {
       //echo "<script type=text/javascript>alert('sss');</script>";
       /*$current_date = date("Y/m/d");
       $input_date = $this->dpDue1->getDate();

       $check_date = new my_library();

       $this->stat->Caption=$check_date->daysDifference('2009/10/26', $current_date);*/


       $this->compid->Value = $_SESSION['company_id'];
       $veh_id = $_GET['veh'];
       $this->hiddenId->setValue($veh_id);

       $this->imgBack->setLink('check_reminder.php?veh='.$this->hiddenId->getValue());

       $this->chkRec->Checked = false;

       $this->dpDue->Text=date('Y-m-d');
       $this->edDesc->Text='';
       $this->edEvery->Text='';
       $this->ednum->Text='';
       $this->edRemind->Text='';
       $this->memoComments->Lines=array();

       $result_veh = mysql_query("select * from vehicle_tbl where vehicle_id='".$this->hiddenId->getValue()."'");
       $row_veh = mysql_fetch_array($result_veh);
       $track = $row_veh['track_by'];
       $this->hftrack->setValue($track);

       //$this->cmbSchedule->AddItem('Mileage', null, 'Mileage');
       //$this->cmbSchedule->AddItem('Hours', null, 'Hours');
       if($track=='distance')
       {
       $this->cmbSchedule->AddItem('Mileage', null, 'Mileage');
       $this->cmbSchedule->ItemIndex = 'Mileage';
       }

       if($track=='hours')
       {
       $this->cmbSchedule->AddItem('Hours', null, 'Hours');
       $this->cmbSchedule->ItemIndex = 'Hours';
       }

       //$this->cmbSchedule->AddItem('Hours', null, 'Hours');
       //$this->cmbSchedule->AddItem('Mileage', null, 'Mileage');
       //start sched by


       $this->cmbType->Clear();
       $this->cmbType->AddItem('--Select--', null, '--Select--');
       $result_type = mysql_query("select * from lookup_reminder_tbl where company_id='".$_SESSION['company_id']."' AND category='type'");

        while($row_type = mysql_fetch_array($result_type))
        {
            $this->cmbType->AddItem($row_type['value'], null, $row_type['value']);
        }

       //list Type
       $this->listType->Clear();
       $result_t = mysql_query("select * from lookup_reminder_tbl where company_id='".$_SESSION['company_id']."' AND category='type'");

        while($row_t = mysql_fetch_array($result_t))
        {
        $this->listType->AddItem($row_t['value'], null, $row_t['value']);
        }


       /*$this->cmbDesc->Clear();
       $result_desc = mysql_query("select * from lookup_workorder_tbl where category='task descriptions'");

        while($row_desc = mysql_fetch_array($result_desc))
        {
            $this->cmbDesc->AddItem($row_desc['value'], null, $row_desc['value']);
        }*/

       $this->cmbVendor->Clear();
       $this->cmbVendor->AddItem('--Select--',null,'--Select--');
       $result_vendor = mysql_query("select vendor_name from vendor_tbl where company_id='".$_SESSION['company_id']."'");

        while($row_vendor = mysql_fetch_array($result_vendor))
        {
            $this->cmbVendor->AddItem($row_vendor['vendor_name'], null, $row_vendor['vendor_name']);
        }

       }

       function btnSubmitClick($sender, $params)
       {
       $current_date = date("Y-m-d");

       $sched = $this->cmbSchedule->getItemIndex();
       /*if($sched=='Date')
       {
       $input_date = $this->dpDue2->getText();
       }
       else
       {
       $input_date = $this->dpDue1->getText();
       }*/
       //die($input_date);
       $input_date = $this->dpDue->getText();

       if($sched!='Hours' || $sched!='Mileage' || $input_date!=null || $input_date!='')
       {
       $check_date = new my_library();
       $days_computed = $check_date->daysDifference($input_date, $current_date);
       if($days_computed<=0)
       {
       $status = 'Due';
       }
       else if($days_computed<=10 && $days_computed!=0)
       {
       $status = 'Warning';
       }
       }

       $hours_save = null;
       $date_save = null;
       if($sched=='Date')
       {
       $date_save = $this->dpDue->getText();
       }
       if($sched=='Hours' || $sched=='Mileage')
       {
       $hours_save = $this->edDue->Text;
       }
       /*if($sched=='Both')
       {
       $hours_save = $this->edDue->Text;
       $date_save = $this->dpDue2->getText();
       }*/


       if($sched=='Mileage' || $sched=='Hours')
       {
         $save_rem = "rem_hours,";
         $save_rem2 = "'".$this->edRemind->Text."',";
       }
       if($sched=='Date')
       {
         $save_rem = "rem_by,rem_time,";
         $save_rem2 = "'".$this->cmbDaysMos->getItemIndex()."','".$this->edRemind->Text."',";
       }

       if($this->chkRec->Checked == true)
       $recurring = '1';
       if($this->chkRec->Checked == false)
       $recurring = '0';

       if($recurring=='1')//recurring reminder per vehicle
       {

       if($sched=='Mileage' || $sched=='Hours')
       {
        $every_hours = $this->edEvery->Text;
        $every_date = '';
        $every_by = '';
       }
       if($sched=='Date' || $sched=='Time')
       {
        $every_hours = '';
        $every_date = $this->ednum->Text;
        $every_by = $this->cmbdm->getItemIndex();
       }
       $insert_recurring = "insert into veh_reminder_tbl (company_id,
       vehicle_id,
       recur_per_veh,
       schedule_by,
       due_hours,
       due_date,
       every_hours,
       every_date,
       every_by,
       ".$save_rem."
       completion_window,
       type,
       description,
       vendor,
       comments,
       status,
       status2)

       values('".$_SESSION['company_id']."',
       '".$this->hiddenId->getValue()."',
       '".$recurring."',
       '".$this->cmbSchedule->getItemIndex()."',
       '".$hours_save."',
       '".$date_save."',
       '".$every_hours."',
       '".$every_date."',
       '".$every_by."',
       ".$save_rem2."
       'WorkOrder',
       '".$this->cmbType->getItemIndex()."',
       '".$this->edDesc->Text."',
       '".$this->cmbVendor->getItemIndex()."',
       '".$this->memoComments->Text."',
       '".$status."',
       '".Pending."')";

       mysql_query($insert_recurring)or die("INSERT REMINDER RECURRING - " . mysql_error());
       }
       if($recurring=='0')//non-recurring reminder per vehicle
       {
       mysql_query("insert into veh_reminder_tbl (company_id,
       vehicle_id,
       schedule_by,
       due_hours,
       due_date,
       ".$save_rem."
       completion_window,
       type,
       description,
       vendor,
       comments,
       status,
       status2)

       values('".$_SESSION['company_id']."',
       '".$this->hiddenId->getValue()."',
       '".$this->cmbSchedule->getItemIndex()."',
       '".$hours_save."',
       '".$date_save."',
       ".$save_rem2."
       'WorkOrder',
       '".$this->cmbType->getItemIndex()."',
       '".$this->edDesc->Text."',
       '".$this->cmbVendor->getItemIndex()."',
       '".$this->memoComments->Text."',
       '".$status."',
       '".Pending."')")or die("INSERT REMINDER - " . mysql_error());
       }

       //redirect('check_reminder.php?veh='.$this->hiddenId->getValue());

       echo "<script type='text/javascript'>
       var answer = confirm('Add another record?');
       if(answer)
       {
       window.location = 'veh_reminder_create2.php?veh=".$this->hiddenId->getValue()."';
       }
       else
       {
       window.location = 'check_reminder.php?veh=".$this->hiddenId->getValue()."';
       }
       </script>";
       }


}

global $application;

global $Veh_Reminder_create;

//Creates the form
$Veh_Reminder_create=new Veh_Reminder_create($application);

//Read from resource file
$Veh_Reminder_create->loadResource(__FILE__);

//Shows the form
$Veh_Reminder_create->show();

?>